<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta content="always" name="referrer">
    <meta name="theme-color" content="#ffffff">
    <link rel='stylesheet' href='/css/base.css' />
    <link rel='stylesheet' href='/css/login.css' />

    <script>
        var showValidateCode = false;
        window.onload = function() {

            const validateCodeDiv = document.getElementById('validateCodeDiv');
            const validCode = document.getElementById('validCode');

            if (showValidateCode) {
                validateCodeDiv.style.display = 'block';
                validCode.disabled = false;
            } else {
                validateCodeDiv.style.display = 'none';
                validCode.disabled = true;
            }

        };

    </script>

</head>

<body>
<% if (request.getAttribute("systemName") != null) { %>
    <div class="header-title">
        <h2>${systemName} </h2>
    </div>
<% } %>

    <div class="page-container">
        <div class="login-container">

            <%-- 显示 Shiro 的认证错误消息 --%>
            <% if (session.getAttribute("shiroLoginFailure") != null) { %>
                <div class="form-group">
                    <p style="color: red;">登录失败：<%= session.getAttribute("shiroLoginFailure") %></p>
                    <% session.removeAttribute("shiroLoginFailure"); // 显示后清除消息 %>
                </div>
            <% } %>

            <form class="login-form" action="/doLogin" method="post">
                <div class="form-group">
                    <label for="username">账号</label>
                    <input type="text" id="username" name="username" value='admin' required>
                </div>
                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" id="password" name="password" value='112233' required>
                </div>
                <!--默认不显示-->
                <div class="form-group" id="validateCodeDiv" style="display:none;">
                    <label for="validCode">请输入验证码</label>
                    <input type="text" id="validCode" name="validCode" required>
                </div>
                <button type="submit">登录</button>
            </form>
        </div>
    </div>

    <!-- 引入加载页脚的脚本 -->
    <script src="/scripts/loadFooter.js"></script>
</body>
</html>